GDIR=../../..
GIMIPATH=$(GDIR)/GIMI
MACIPATH=$(GDIR)/MaCI
## Build GIMI and it's dependencies.
## Files are set to CGIMI and CPPGIMI variables
include $(GIMIPATH)/Makefile.gimi

## Include MaCI-stuff
include $(MACIPATH)/interfaces/MaCI-interfaces.Makefile


LD=g++
LDFLAGS=
LIBS=-lrt -lpthread `xml2-config --libs` `wx-config --libs std,gl --unicode=no`	\
	-lSDL_gfx -lSDL_image  -lglut -lGL $(LIBSGIMI)

SRCSC= $(MACI_INTERFACE_IMAGE_EXT_C)
SRCSCPP=

GIMBOPATH=$(GDIR)/Gimbo
VPATH=
CPPGIMI=
CGIMI=


CC=gcc
CXX=g++
CFLAGS=-Wall $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS) $(CE)
CPPFLAGS=$(DEBUG) $(CPPINCLUDES) $(DEFINITIONS) $(CPPMISCFLAGS) $(CE)
DCPPFLAGS=$(DEBUG) $(CPPINCLUDES) $(DEFINITIONS) $(CE)
DEBUG=-O0 -g3
CMISCFLAGS=
CPPMISCFLAGS=-Wall -Wunused -Wshadow -Weffc++
DEFINITIONS=-DLINUX_OS -DGIMI_NO_DATATYPE_INCLUDES $(CE)
CINCLUDES=-I. -I../../ $(INCGIMI)
CPPINCLUDES=-I. -I../../ \
		`xml2-config --cflags` \
		`wx-config --cflags --unicode=no` \
		$(MACI_INCLUDE_PATHS) \
	  $(INCGIMI) \
		-I$(GDIR)/MaCIApps/FleetFormationController

## Build GIMI and it's dependencies.
## Files are set to CGIMI and CPPGIMI variables
include $(GIMIPATH)/Makefile.gimi

## Include MaCI-stuff
include $(MACIPATH)/interfaces/MaCI-interfaces.Makefile

## Define GIMBO sources
GIMBOSRCSC= $(MACI_INTERFACE_IMAGE_EXT_C)
GIMBOSRCSCPP=$(GIMBOPATH)/Component.cpp

## Construct final lists of CPP and C objects
OBJSC=$(CGIMI:.c=.o) $(GIMBOSRCSC:.c=.o)
OBJSCPP=$(CPPGIMI:.cpp=.opp) \
	$(MACI_BASE_SRC_CPP:.cpp=.opp) \
	$(MACI_EXT_SRC_CPP:.cpp=.opp) \
	$(GIMBOSRCSCPP:.cpp=.dopp)\
	$(MACI_INTERFACE_POSITION_COMMON_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_POSITIONCLIENT_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_SPEEDCTRL_COMMON_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_SPEEDCTRLCLIENT_CPP:.cpp=.opp) \
	$(MACI_INTERFACE_SPEEDCTRLSERVER_CPP:.cpp=.opp)



## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c
COMPILEDCPP=$(CXX) $(DCPPFLAGS) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean

TARGETS=FleetFormationGUI FleetFormationGUIWX

all: $(TARGETS)


FleetFormationGUI: $(OBJSC) $(OBJSCPP) \
	FleetFormationGUI.opp\
	$(GDIR)/MaCIApps/FleetFormationController/FleetFormationController.opp \
	main.opp	
	@$(LINK) -o $@ $^
	@echo "      [LD] $@"

FleetFormationGUIWX: $(OBJSC) $(OBJSCPP) \
	FleetFormationGUIMainFrame.dopp \
	$(GDIR)/MaCIApps/FleetFormationController/FleetFormationController.opp \
	FleetFormationWXGUI.dopp\
	FleetFormationWX.dopp\
	FleetFormationWXGLFrame.dopp

	@$(LINK) -o $@ $^
	@echo "      [LD] $@"


clean:
	@rm -f *.dopp *.opp *.o *~ players/*.opp $(TARGETS)
	@echo "      [CLEAN]"

realclean: clean
	@rm -f *.state *.log $(OBJSC) $(OBJSCPP) $(GIMIPATH)/MaCIApps/FleetFormationController/FleetFormationController.opp
	@echo "      [REALCLEAN]"


## Below this is dependency generation stuff, no need to change.
## Compile rule for all .o (.c) file
%.o:    %.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

## Compile rule for all .opp (.cpp) files
%.opp:  %.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"

# Compile rule for all .dopp (dirty .cpp) files
%.dopp:	%.cpp
	@$(COMPILEDCPP) -o $@ $<
	@echo "      [DIRTY-CXX] $<"

